package com.consumer.controller;

import com.springcloud.api.common.CommonResult;
import com.springcloud.api.entities.ArticleEntity;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@RestController
public class ConsumerController {
    public static final String PAYMENT_URL = "http://SPRING-CLOUD-PROVIDERS";

    @Resource
    private RestTemplate restTemplate;

    @GetMapping("/providers/discovery")
    public CommonResult<List<ArticleEntity>> get() {
        return restTemplate.getForObject(PAYMENT_URL + "/providers/discovery",CommonResult.class);
    }

}
